package com.dlut.txy.designpattern.schedule.task.impl;

import com.dlut.txy.designpattern.schedule.entity.User;
import com.dlut.txy.designpattern.schedule.task.ScheduleTask;
import com.dlut.txy.designpattern.schedule.task.ScheduleTaskParam;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Calendar;

@Slf4j
public class QueryUserStatusTask extends ScheduleTask {
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

    @Override
    public String getTaskId() {
        return super.param.getParam(ScheduleTaskParam.Key.userBid).toString();
    }

    public QueryUserStatusTask(ScheduleTaskParam param) {
        super(param);
    }

    public Object execute() {
//        log.info("查询用户状态 param={}", param.getParam(ScheduleTaskParam.Key.userBid));
        Calendar calendar = Calendar.getInstance();
        User user = new User(Integer.parseInt(param.getParam(ScheduleTaskParam.Key.userBid).toString()),
                sdf.format(calendar.getTime()), 1);
        return user;
    }
}
